<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@page import="servlet.SelectState" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Contact Us</title>
<%	
	ArrayList state=new ArrayList();
	SelectState stateSelect=new SelectState();
	state=stateSelect.StateCitySelect();
%>
</head>
<body bgcolor=grey>

<div style="width:100%">
		<%@include file="Menu.jsp" %>
	</div>

<table width=98% bgcolor=#97aa58>
	<tr>
		<td colspan=3></td>
		<td colspan=2 align="right"><a href="Login.jsp">Login</a></td>
	</tr>
	
	
	
	<tr>
		<td colspan=1>Contact Us : <br>A-61 1st Floor,Sector-65<br>Noida (Uttar Pradesh)<br>(M)9899685362</br></td>
		<td colspan=4>Request Form<hr></hr>
		 	<form name=RequestForm method=post action=/PropertySite/submitCustomerDataServlet onSubmit="return isEmpty()">
		 	<table>
		 	    <tr>
		 	       <td>Name<font color=red><ilayer name=asterisk1 left=5 top=-25>*</ilayer></font></td>
		 	       <td><input type="text" name="nametxt" id="nametxt" size=20></input></td>
		 	     </tr> 
		 	     <tr>
		 	     	  <td>E-Mail<font color=red><ilayer name=asterisk1 left=5 top=-25>*</ilayer>
		 	     	  <td><input type="text" name="emailtxt" id="emailtxt" size=20 ></input></td>
		 	     </tr>
		 	     <tr>
		 	     	  <td>Phone 1<font color=red><ilayer name=asterisk2 left=5 top=-25>*</ilayer></font></td>
		 	     	  <td><input type="text" name="phone1txt" id="phone1txt" size=20 maxlength=13 onkeypress="return onlyNumbers();"></input></td>
		 	     </tr>
		 	     <tr>
		 	     	   <td>Phone 2</td>
		 	     	   <td><input type="text" size=20 name="phone2txt" maxlength=13></input></td>	
		 	     </tr>
		 	     <tr>
		 	     	   <td>Address 1</td>
		 	     	   <td><input type=text size=20 name="Addresstxt"></input></td>
		 	     </tr>
		 	     <tr>
		 	     		<td>Address 2</td>
		 	     		<td><input type=text size=20 name="Address2txt"></input></td>
		 	     </tr>
		 	     <tr>
		 	     		<td>State</td>
		 	     		<td><select name="state" id="state" onchange="showCity()">
		 	     				<option>--select--</option>
		 	     				
		 	     					<%	
		 	     					
		 	     					int i;
		 	     					for(i=0;i<state.size();i++)		
		 	     					{		
		 	     	    			%>						
		 	     					<option><%=state.get(i)%></option>
		 	     		    		<%	
		 	     				    } 
		 	     				
		 	     			    	%>		
		 	     				
		 	     			</select>
		 	     		</td>
		 	     		<td>City</td>
		 	     		<td>
		 	     			<span id="loadCity">
		 	     			<select><option>--select--</option></select>
		 	     			</span>
		 	     		</td>
		 	     		
		 	     </tr>
		 	     <tr>
		 	     	   <td>Flat Requirement</td>
		 	     	   <td><Select name="Flat">
		 	     	           <option>2 BHK</option>
		 	     	           <option>3 BHK</option>
		 	     	           <option>4 BHK</option>
		 	     	       </Select></td>	
		 	     </tr>
		 	     <tr>
		 	     	   <td>Budget </td>
		 	     	   <td><select name="Budget">
		 	     	   	       <option>10lakh-30lakh</option>
		 	     	   	       <option>30lakh-60lakh</option>
		 	     	   	       <option>60lakh-90lakh</option>
		 	     	   	       <option>90lakh-1crore</option>
		 	     	   	       <option>Above 1crore</option>
		 	     	   	      </select> 
		 	     	   </td>	
		 	     </tr>
		 	     <tr>
		 	     	   <td>Location</td>
		 	     	   <td><select name="Location">
		 	     	   			<option>Noida</option>
		 	     	   			<option>Greater Noida</option>
		 	     	   			<option>Gaziabad-Indirapuram</option>
		 	     	   			<option>Gaziabad</option>
		 	     	       </select></td>	
		 	     </tr>
		 	     <tr>
		 	     	   <td><input type=submit value="Submit" ></input>
		 	     	   <td><input type=Button value="Cancel"></td>	
		 	     </tr>
		 	     
		 	       
		    </table>
		    </form>
		</td> 	
	</tr>
</table>

<hr><h5>Field marked with asterisk are mandatory</h5></hr>
</body>

<script language="javascript">


var xmlrequest=false;  
//xmlrequest=AjaxFunction();
function AjaxFunction()  
{  
     
	 try
		{	xmlrequest=new XMLHttpRequest(); 	}
		catch(e)
		{
			try{
				xmlrequest=new ActiveXObject("Msxml2.XMLHTTP");
			   }
			catch(e)
			   {
				   xmlrequest=new ActiveXObject("Microsoft.XMLHTTP");
			   }	   

		}
		return xmlrequest;	
}   
function showCity()  
{  
     var selectindex=document.getElementById("state").selectedIndex;
 	 var selectstate=document.getElementById("state").options[selectindex].text;
     var url="http://localhost:8181/PropertySite/getCityServlet";
         url=url+"?statename="+selectstate; 
         alert(url);
     xmlrequest=AjaxFunction();
     xmlrequest.open("GET",url,true);   
     xmlrequest.onreadystatechange=function()
     {
    	 if(xmlrequest.readyState==4)  
    	    {  
    	         if(xmlrequest.status==200)  
    	         {  
    	             document.getElementById("loadCity").innerHTML=xmlrequest.responseText;  
    	         }  
    	    }    
     };    
     xmlrequest.send(null);  
}  


	/*function onlyNumbers(evt)
	{
		var e=event||evt;
		var charcode=e.which||e.keyCode;
		if(charcode>31 && (charcode<48||charcode>57 )
			return false;
		return true;
	}*/

	var emailstring=document.getELementById("emailtxt").value;
	var emailresult;
	function isEmpty()
	{
			
			if(document.getElementById("nametxt").value==0)
				{
					alert("Name Filed cannot be empty");
				    return false;
				}
			if(document.getElementById("phone1txt").value==0)
			    {
					alert("Phone1 Filed cannot be empty");
			    	return false;
			    }
			if(document.getElementById("emailtxt").value==0)
		        {
					alert("Email Filed cannot be empty");
		    		return false;
		        }
		    return true;
	}	
	
	function checkEmail()
	{
		
		alert(emailstring);
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if(filter.test(emailstring))
			emailresult=true;
		else
		{
			alert("please enter valid email address");
			emailresult=false;
		}
		return emailresult;	
				
	}	    
</script>
</html>